define(function (require, exports, module) {
	require("resource/css/backDialog.css");
	require('resource/js/easyui/themes/bootstrap/linkbutton.css');
	require('resource/font-awesome-4.7.0/css/font-awesome.min.css');
	require('resource/font-awesome-4.7.0/css/icomoon.css');
	exports.openBackDialog = function(config){
		var conf = {
			href:'',
			content:'',
			title:'myDialog',
			buttons:[
			    //{text:'',icon:'',haddle:function(){}}
			],
			onLoad:function(){
				
			},
			backLoadHref: "", //返回加载的url
			backLoadFun: function() { //返回回调方法
			}
		};
		for(var key in config){
			conf[key] = config[key];
		}
		var eles = $(".dialog-back-btn");
		if(eles!=undefined&&eles.length==0){
			var html = '<div class="backDlgPage">'
							+'<div class="dlg-head">'
							+ '<a href="javascript:void(0);" class="dlg-goback l-btn l-btn-small l-btn-wright"><span class="l-btn-left l-btn-icon-left">'
							+ '<span class="l-btn-icon icon-icomoon-balck">&nbsp;</span>'
							+ '<span class="l-btn-text l-btn-postion-all">返回</span>'						
							+ '</span>'
							+ '</a>';
			//+'<a href="javascript:void(0);" class="dlg-goback dlg-buttons"><i class="back-icon"></i><span class="dlg-btn-text">返回<span></a>'
		
			if(conf.title){
				html+='<label class="dlg-title-span"><span>'+conf.title+'</span></label>';
			}
			
			html+='</div><div class="dlg-body">';
			if(conf.href){
				html+='<iframe width="100%" style="border: 0" height="100%" src="'+conf.href+'"></iframe>';
			}else if(conf.content){
				html+=conf.content;
			}else{
				console.log('加载内容错误！');
			}
			html+='</div><div>';
			$('body').append(html);
			$('.dlg-body').height($('body').height()-$('.dlg-head').outerHeight());
			$('.dlg-goback').bind('click',function(){
				$(".backDlgPage").remove();
				if (conf.backLoadHref != '') {
					window.location.href = BASEPATH + conf.backLoadHref;
				}
				if (conf.backLoadFun) {
					conf.backLoadFun();
				}
			});
			if(conf.buttons&&conf.buttons.length>0){
				var left=10+78+12;
				$.each(conf.buttons,function(i,btn){
					var thisBtn ='<a href="javascript:void(0);" class="l-btn l-btn-small l-btn-wright">'
						+'<span class="l-btn-left l-btn-icon-left">'
						+ '<span class="l-btn-icon fa '+ btn.icon +'" aria-hidden="true">&nbsp;</span>'
						+ '<span class="l-btn-text">'+btn.text+'</span>'						
						+ '</span>'
						+ '</a>';
					
					var ele = $(thisBtn).insertAfter('.dlg-goback').on('click',function(){
						if(btn.haddle){
							btn.haddle();
						}
					});
					ele.attr('style','left:'+left+'px');
					left = left + ele.outerWidth()+ 12;
				});
			}
		}
		//加载完成执行事件
		if(conf.onLoad){
			conf.onLoad();
		}
	};
});